#include "D3D9_PCH.h"
#include "D3D9Device.h"
#include "MeshComponent.h"

CMeshComponent::CMeshComponent(void)
{
	ZeroMemory(&m_mtrlDefault, sizeof(D3DMATERIAL9));
	m_mtrlDefault.Ambient = D3DXCOLOR( 1, 1, 1, 1 );	
	m_mtrlDefault.Diffuse = D3DXCOLOR( 1, 1, 1, 1 );
	m_mtrlDefault.Specular = D3DXCOLOR( 1, 1, 1, 1 );
	m_mtrlDefault.Emissive = D3DXCOLOR( 0, 0, 0, 1 );
	m_mtrlDefault.Power = 5.0f;
}

CMeshComponent::~CMeshComponent(void)
{
	SAFE_RELEASE(m_pMesh);
}

void CMeshComponent::Render() const {

//	D3DXMATRIX matTransform;
//	D3DXMatrixIdentity( &matTransform );
//	D3DXMatrixAffineTransformation( &matTransform, 10, NULL, &(m_rRotation.toQuaternion()), &m_vPosition );
//	g_pDevice->SetTransform( D3DTS_WORLD, &matTransform );

	if ( m_pMesh != NULL ) {
		g_pDevice->SetTexture(0, NULL);
		g_pDevice->SetMaterial( &m_mtrlDefault );
		m_pMesh->DrawSubset(0);
	}
}